<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function foo(m, n) {
      // arguments 类似数组对象
      console.log(arguments)
      // 通过索引获取内容
      console.log(arguments[0])
      console.log(arguments[1])
      console.log("===========")
      for (var i = 0; i < arguments.length; i++) {
        console.log(arguments[i])
      }
      console.log("===========")
      for (var arg of arguments) {
        console.log(arg)
      }
      console.log("=====获取所有的偶数======")
      for (var arg of arguments) {
        if (arg % 2 === 0) {
          console.log(arg)
        }
      }
      
      // Uncaught TypeError: arguments.filter is not a function
      // console.log(arguments.filter(item => item % 2 === 0)) 

      console.log("=====2.1将arguments转成数组一======")
      var newArguments = []
      for (var arg of arguments) {
        newArguments.push(arg)
      }
      console.log(newArguments)

      console.log("=====2.2将arguments转成数组二:调用slice")
      var newArgs = [].slice.apply(arguments)
      console.log(newArgs)


      console.log("=====2.3将arguments转成数组三:ES6======")
      var newArgs1 = Array.from(arguments)
      console.log(newArgs1)
      var newArgs2 = [...arguments]
      console.log(newArgs2)
    }


    foo(10, 25, 32, 41)

  </script>
</body>

</html>